import { createParamDecorator, ExecutionContext } from '@nestjs/common';

interface UserPayload {
  id: string;
  account: string;
  [key: string]: any;
}

/**
 * 获取当前用户信息
 */
export const CurrentUser = createParamDecorator(
  (ctx: ExecutionContext): UserPayload => {
    const request = ctx.switchToHttp().getRequest();
    const user: UserPayload = request.user;
    return user;
  },
);
